﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AGVControlSystemPro
{
    public partial class Node : System.Windows.Forms.Label
    {
        private System.Drawing.Pen _pen;
        private int _PenWidth = 2;//线宽，描边的线的宽度
        private System.Drawing.Rectangle EllipseRect;//边缘尺寸
        //public Node()
        //{
        //    InitializeComponent();

        //}
        public Node()
            : base()
        {
                //InitializeComponent();
                EllipseRect = new System.Drawing.Rectangle(0,0,150,150);
        }
        protected override void InitLayout()
        {
            System.Drawing.Drawing2D.GraphicsPath path =
            new System.Drawing.Drawing2D.GraphicsPath();
            path.AddEllipse(this.ClientRectangle);
            EllipseRect = this.ClientRectangle;
            EllipseRect.Width -= (_PenWidth + 1);
            EllipseRect.Height -= (_PenWidth + 1);
            this.Region = new System.Drawing.Region(path);
            base.InitLayout ();
        }

        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
        {
            base.OnPaintBackground(pevent);
            if (_pen == null)
            {
                _pen = new System.Drawing.Pen(this.ForeColor, _PenWidth);
            }
            pevent.Graphics.DrawEllipse(_pen, EllipseRect);
        }
    }
}
